package academic.emailClient.control.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.UUID;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import academic.emailClient.model.EmailClientModel;
import academic.emailClient.view.EmailClientViewInterface;

public class DeclineMeetingButtonActionListener implements ActionListener{
	private EmailClientViewInterface view;
	private EmailClientModel model;
	
/**
 * constructor
 * 	
 * @param view
 * @param model
 */
	public DeclineMeetingButtonActionListener(EmailClientViewInterface view, EmailClientModel model) {
		super();
		this.view = view;
		this.model = model;
	}

	/**
	 * Handle Filter Menu Button nMessage event
	 */
	public void actionPerformed(ActionEvent e) {
		model.declineMeeting(view.getMeetingId());
		JOptionPane.showMessageDialog(new JPanel(),
				"Meeting is Declined. Meeting owner is being notified",
				"Information",
				JOptionPane.INFORMATION_MESSAGE);
		ArrayList<UUID> selectedMessages = view.getSelectedMessages();
		String folderPath = view.getSelectedFolderPath();
		model.deleteMessages(folderPath, selectedMessages);
		view.deleteSelectedMessages();
	}
}